// webemMT.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/function.hpp>

#include "../../src/Webem/cWebem.h"

/// An application class which says hello
class cHello
{
public:
	char * DisplayHTML()
	{
		return "<em>Hello World</em>";
	}
};

/**

  Tell user twhere to find the cWebem GUI

*/
void splash( char * port )
{
	char buf[1000];
	DWORD bufsize = 999;
	GetComputerNameEx( ComputerNameDnsHostname,
		buf,
		&bufsize );
	printf("		cWebem Hello Server\n\n"
		   "		Point browser at http://%s:%s\n",
		buf,
		port );
}



int _tmain(int argc, _TCHAR* argv[])
{
	// Initialize application code

	cHello hello;

	// Initialise web server.

    http::server::cWebem theServer(
		"0.0.0.0",						// address
		"1570",							// port
		".\\");							// document root

	// register application method
	// Whenever server sees <!--#webem hello -->
	// call cHello::DisplayHTML() and include the HTML returned

	theServer.RegisterIncludeCode( "hello", 
		boost::bind( 
		&cHello::DisplayHTML,	// member function
		&hello ) );			// instance of class


	splash( "1570" );

	// run the server
	theServer.Run();

	return 0;
}

